<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background: palegoldenrod;
        }
    </style>
</head>
<body>
    <button>移除事件</button>
    <div></div>
    <script>
        var box = document.querySelector('div')
        var btn = document.querySelector('button')

        box.onclick = function(){
            console.log(1)
        }
        box.onclick = function(){
            console.log(2)
        }
        btn.onclick = function(){
            box.onclick = null;
        }
    </script>
</body>
</html>